home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / MacApp / Unsupported Samples / MacApp Drafter / Source / UMacApp® Drafter.h < prev   
Encoding:
C/C++ Source or Header  |  1990-07-13  |  15.2 KB  |  478 lines  |  [TEXT/MPS ]

  1. /*******************************************************************************
  2. *
  3. * Application:   MacApp® Drafter, a sample C++ program by Danie Underwood
  4. *
  5. * File:   UMacApp® Drafter.h
  6. *
  7. * Description: Main Program
  8. *
  9. * Apple Integrated Systems
  10. *
  11. * ©1990 Apple Computer, Inc. All rights reserved.
  12. *
  13. ********************************************************************************/
  14.  
  15. #ifndef  __UDrafter__
  16. #define __UDrafter__  0
  17. #endif
  18.  
  19. #if  ! __UDrafter__
  20. #define __UDrafter__  1
  21.  
  22. #include "UMacAppUtilities.h"
  23. #include "UPrinting.h"
  24. #include "UTEView.h"
  25. #include "UGridView.h"
  26. #include "UDialog.h"
  27. #include "Memory.h"
  28. #include "Packages.h"
  29. #include "ToolUtils.h"
  30. #include "Errors.h"
  31. #include "Files.h"
  32. #include "Fonts.h"
  33. #include "Resources.h"
  34. #include "StdIO.h"
  35. #include "Strings.h"
  36.  
  37. #include "UMacApp.h"
  38.  
  39. //••••• Temporary until MPW catches up
  40. struct XWEventInfo {
  41.     WindowPtr ownerWindow;
  42.     EventRecord theEvent;
  43.     long eventParams[10];
  44. };
  45.  
  46. typedef struct XWEventInfo XWEventInfo;
  47. typedef XWEventInfo *XWEventInfoPtr;
  48.  
  49. //General view signatures for use in dialogs and windows everywhere:
  50.  
  51. const long vMainView            ='MAIN';
  52. const long vTEView                ='EDIT';
  53. const long vNoView                ='NO__';
  54. const long vYesView                ='YES_';
  55.  
  56. //Specific view signatures:
  57.  
  58. const long vAuthors                ='AUTH';
  59. const long vAppName                ='EDIT';    //first selected TE in dialog
  60. const long vCopyRight            ='©CPY';
  61. const long vHasDocs                ='DOCS';
  62. const long vDocBndl                ='DBND';
  63. const long vHasPrefs            ='PREF';
  64. const long vFreeWinds            ='FREW';
  65. const long vPrints                ='PRNT';
  66. const long vSplashes            ='SPLH';
  67. const long vAppSig                ='EDIT';    //first selected TE in dialog
  68. const long vAppSigHex            ='ASGH';
  69. const long vMinMem                ='MINM';
  70. const long vDefaultMem            ='DEFM';
  71. const long vVersDVL                ='VDVL';
  72. const long vVersAlpha            ='VALP';
  73. const long vVersBeta            ='VBTA';
  74. const long vVersRls                ='VRLS';
  75. const long vReleaseNo            ='RLSN';
  76. const long vVersNo                ='VRSN';
  77. const long vBuildNo                ='BLDN';
  78. const long vAppIcon                ='AICN';
  79. const long vDocIcon                ='DICN';
  80. const long vPrefFileName        ='EDIT';
  81. const long vSys7PrefLoc            ='SY7P';
  82. const long vSys6PrefLoc            ='SY6P';
  83. const long vAppPrefLoc            ='APPF';
  84. const long vFileSet                ='FSET';
  85. const long vOneSourceFile        ='1FIL';
  86. const long vStdSourceFiles        ='SFIL';
  87. const long vStdNoInclSrcFil        ='SNIF';
  88. const long vMainName            ='EDIT';
  89. const long vPascal                ='PASC';
  90. const long vCPlusPlus            ='C++_';
  91. const long vDocSig                ='DSIG';
  92. const long vDocSigAlt            ='EDIT';
  93. const long vDocSigHex            ='DSHX';
  94. const long vReadCluster            ='RCLS';
  95. const long vWriteCluster        ='WCLS';
  96. const long vDocReads            ='DREA';
  97. const long vDocWrites            ='DWRI';
  98. const long vReadData            ='DRDT';
  99. const long vReadRsrc            ='DRRS';
  100. const long vRDataOpen            ='DRDO';
  101. const long vRRsrcOpen            ='DRRO';
  102. const long vWriteData            ='DWDT';
  103. const long vWriteRsrc            ='DWRS';
  104. const long vWDataOpen            ='DWDO';
  105. const long vWRsrcOpen            ='DWRO';
  106. const long vDocReverts            ='DRVT';
  107. const long vUsesLists            ='ULST';
  108. const long vUsesAssoc            ='UASS';
  109. const long vViewsRefViews        ='VRVW';
  110. const long vViewsArePrefs        ='VWPF';
  111. const long vSepPrintViews        ='PRVW';
  112. const long vUseGridView            ='GRDV';
  113. const long vUseTEView            ='TEVW';
  114. const long vUseDialogView        ='DLGV';
  115. const long vAppDoesMenus        ='AMNU';
  116. const long vWdwDoesMenus        ='WMNU';
  117. const long vDocDoesMenus        ='DMNU';
  118. const long vViewDoesMenus        ='VMNU';
  119. const long vPopMenus            ='PMNU';
  120. const long vTearMenus            ='TMNU';
  121.  
  122. //Button view signatures for linking between screens like HyperCard® buttons:
  123.  
  124. const long vMainScreen            ='1001';
  125. const long vMainScreenValue        =1001;        //Numeric equivalent of vMainScreen
  126. const long vAppInfo                ='1002';
  127. const long vFinderInfo            ='1003';
  128. const long vPrefs                ='1004';
  129. const long vDocs                ='1005';
  130. const long vDocViews            ='1006';
  131. const long vPgmFiles            ='1007';
  132. const long vMenus                ='1008';
  133. const long vGenerateOutput        ='1111';    //••Exception- this button is different!
  134. const long vGenOutputValue        =1111;        //Numeric equivalent of vGenerateOutput
  135.  
  136. //File pass constants
  137.  
  138. const short kMainFile            =1;
  139. const short kInterfaceFile        =2;
  140. const short kImplementationFile    =4;
  141. const short kResource            =8;
  142. const short kMakeFile            =16;
  143.  
  144.  
  145.  
  146.  
  147.  
  148. //This class defines a special TWindow for the standard file package’s window.
  149.  
  150. class TClearWindow : public TWindow {
  151.   public:
  152.       ResType            fDismissView;        //Who dismissed me?
  153.       short            fSFHitItem;            //What item number was last hit?
  154.  
  155.     virtual pascal void IWindow(TDocument *itsDocument,GrafPtr itsWMgrWindow,Boolean canResize,
  156.        Boolean canClose,Boolean disposeOnFree);
  157.     virtual pascal void Free(void);
  158.     virtual pascal void Activate(Boolean entering);
  159.     virtual pascal Boolean AllowsMenuAccess(void);
  160.     virtual pascal void DrawContents(void);
  161.     virtual pascal ResType GetDisMissView(void);
  162.     virtual pascal Boolean HandleMouseDown(VPoint *theMouse,EventInfo *info,Point *hysteresis,struct TCommand **theCommand);
  163.     virtual pascal void HitItem(short itemNumber);
  164.     virtual pascal short LastItemHit(void);
  165.     virtual pascal void SetDisMissView(ResType viewId);
  166.     virtual pascal void Update(void);
  167. };
  168.  
  169. //This class defines a special TDialogView for the standard file package’s window.
  170.  
  171. class TClearDialog : public TDialogView {
  172.   public:
  173.  
  174.     virtual pascal void DoChoice(TView *origView,short itsChoice);
  175.     virtual pascal void Draw(Rect *area);
  176.     virtual pascal void SetOkEnable(Boolean okIsOn);
  177. };
  178.  
  179.  
  180. //This class defines a TCluster with split drawing methods and subview clip out.
  181. //It also coordinates its states with its subviews.
  182.  
  183. class TDrafterCluster : public TCluster {
  184.   public:
  185.  
  186.     virtual pascal void Draw(Rect *area);
  187.     virtual pascal void DrawInterior(Rect *area,Rect *insideRect);
  188.     virtual pascal void DimState(Boolean state, Boolean redraw);
  189.     virtual pascal void DrawTitle(Rect *area);
  190.     virtual pascal Boolean SetClipRgn(void);
  191. };
  192.  
  193. //This class defines a TDrafterCluster but without the subview clip out.
  194.  
  195. class TDrafterNoClipCluster : public TDrafterCluster {
  196.   public:
  197.  
  198.     virtual pascal Boolean SetClipRgn(void);
  199. };
  200.  
  201. //This class defines a TDrafterCluster with shadowed borders.
  202.  
  203. class TDrafterFrameCluster : public TDrafterCluster {
  204.   public:
  205.  
  206.     virtual pascal void Draw(Rect *area);
  207.     virtual pascal void DrawInterior(Rect *area,Rect *insideRect);
  208.     virtual pascal void DrawTitle(Rect *area);
  209. };
  210.  
  211. //This class defines a TDrafterFrameCluster but without the subview clip out.
  212.  
  213. class TDrafterHollowCluster : public TDrafterFrameCluster {
  214.   public:
  215.  
  216.     virtual pascal Boolean SetClipRgn(void);
  217. };
  218.  
  219. //This class defines a TDrafterHollowCluster painted in an RGBColor from a resource.
  220.  
  221. class TDrafterBrassCluster : public TDrafterHollowCluster {
  222.   public:
  223.  
  224.     virtual pascal void Draw(Rect *area);
  225. };
  226.  
  227. //This class defines a TDrafterCluster that doesn’t draw at all.
  228. //It is only used to coordinate its subviews.
  229.  
  230. class TDrafterClearCluster : public TDrafterCluster {
  231.   public:
  232.  
  233.     virtual pascal void Draw(Rect *area);
  234. };
  235.  
  236.  
  237. //This class defines a TWindow that appears similar to a HyperCard background.
  238.  
  239. class TDrafterWindow : public TWindow {
  240.   public:
  241.  
  242.     virtual pascal void DrawContents(void);
  243.     virtual pascal void SwitchDialog(short newViewId);
  244. };
  245.  
  246.  
  247. //This class defines a TButton that links screens like HyperCard buttons can.
  248.  
  249. class TDrafterButton : public TButton {
  250.   public:
  251.     virtual pascal void Open(void);
  252. };
  253.  
  254.  
  255. //This class defines a TDialogTEView which is coordinated with other views.
  256.  
  257. class TDrafterDialogTEView : public TDialogTEView {
  258.   public:
  259.  
  260.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  261.     virtual pascal TTETypingCommand *DoMakeTypingCommand(short ch);
  262.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  263. };
  264.  
  265. //This class defines a TDialogView that is similar to a HyperCard card.
  266.  
  267. class TDrafterView : public TDialogView {
  268.   public:
  269.  
  270.     virtual pascal void DoChoice(TView *origView,short itsChoice);
  271.     virtual pascal class TDrafterDoc *GetDrafterDoc(void);
  272.     virtual pascal struct TDialogTEView *MakeTEView(void);
  273.     virtual pascal void Open(void);
  274. };
  275.  
  276. //This class defines a TDrafterView for the general information screen.
  277.  
  278. class TDlgGeneral : public TDrafterView {
  279.   public:
  280.  
  281.     virtual pascal void Close(void);
  282.     virtual pascal void DoChoice(TView *origView,short itsChoice);
  283.     virtual pascal void Open(void);
  284. };
  285.  
  286. //This class defines a TDrafterView for the Finder information screen.
  287.  
  288. class TDlgFinderInfo : public TDrafterView {
  289.   public:
  290.  
  291.     virtual pascal void Close(void);
  292.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  293.     virtual pascal void Open(void);
  294. };
  295.  
  296. //This class defines a TDrafterView for the preferences information screen.
  297.  
  298. class TDlgPrefs : public TDrafterView {
  299.   public:
  300.  
  301.     virtual pascal void Close(void);
  302.     virtual pascal void Open(void);
  303. };
  304.  
  305. //This class defines a TDrafterView for the document information screen.
  306.  
  307. class TDlgDocs : public TDrafterView {
  308.   public:
  309.  
  310.     virtual pascal void Close(void);
  311.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  312.     virtual pascal void Open(void);
  313. };
  314.  
  315. //This class defines a TDrafterView for the view information screen.
  316.  
  317. class TDlgViews : public TDrafterView {
  318.   public:
  319.  
  320.     virtual pascal void Close(void);
  321.     virtual pascal void Open(void);
  322. };
  323.  
  324. //This class defines a TDrafterView for the build screen.
  325.  
  326. class TDlgBuild : public TDrafterView {
  327.   public:
  328.  
  329.     virtual pascal void Close(void);
  330.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  331.     virtual pascal void Open(void);
  332. };
  333.  
  334. //This class defines a TDrafterView for the menus screen.
  335.  
  336. class TDlgMenus : public TDrafterView {
  337.   public:
  338.  
  339.     virtual pascal void Close(void);
  340.     virtual pascal void Open(void);
  341. };
  342.  
  343.  
  344.  
  345. //This class defines a TDocument as a general data storage object.
  346.  
  347. class TDrafterDoc : public TDocument {
  348.   public:
  349.       long                    fSpinState;            //Busy cursor state
  350.       TAssociation            *fWhatsBeenSeen;    //A set of buttons that have been clicked.
  351.  
  352.     TIcon                    *fAppIcon;            //NOT IMPLEMENTED
  353.     TIcon                    *fDocIcon;            //NOT IMPLEMENTED
  354.     OSType                    fSignature;            //USER:Application’s signature
  355.     OSType                    fDocType;            //USER:Document’s file type
  356.     long                    fMinMem;            //USER:SIZE resource min
  357.     long                    fStandardMem;        //USER:SIZE resource standard
  358.     short                    fVersVersion;        //USER:version number
  359.     short                    fVersRelease;        //USER:release number
  360.     short                    fVersBuild;            //USER:version.release build number
  361.     Byte                    fVersType;            //USER:final, beta, alpha or development
  362.       Boolean                    fFreeWindows;        //USER:it has free windows
  363.       Boolean                    fHasPrefs;            //USER:it has preference file
  364.       Boolean                    fPrefInSystem6;        //USER:store prefs system 6 place
  365.       Boolean                    fPrefInSystem7;        //USER:store prefs system 7 place
  366.       Boolean                    fPrefWithApp;        //USER:store prefs with app
  367.       Boolean                    fOneFile;            //USER:generate one program source file
  368.       Boolean                    fUseIncludes;        //USER:generate implementation include file
  369.       Boolean                    fPascal;            //USER:generate Object Pascal
  370.       Boolean                    fFloaters;            //USER:it has floatoids
  371.       Boolean                    fTearOffMenus;        //USER:it has tear offs
  372.       Boolean                    fHierMenus;            //USER:it has hierarchials
  373.       Boolean                    fSplash;            //USER:it has a splash screen
  374.       Boolean                    fLaunchWithDoc;        //USER:it defaults to untitled doc
  375.       Boolean                    fHasDocs;            //USER:it has documents
  376.       Boolean                    fPrints;            //USER:it prints
  377.       Boolean                    fAssociation;        //USER:it uses associations
  378.       Boolean                    fLists;                //USER:it uses lists
  379.       Boolean                    fTEView;            //USER:it uses text edit views
  380.       Boolean                    fDialogView;        //USER:it uses dialogs
  381.       Boolean                    fGridView;            //USER:it uses gridviews
  382.       Boolean                    fAppDoesMenuCommands;    //USER:it has application wide commands
  383.       Boolean                    fWindowDoesMenuCommands;    //USER: windows own commands
  384.       Boolean                    fDocDoesMenuCommands;    //USER: documents own commands
  385.       Boolean                    fViewDoesMenuCommands;    //USER: views own commands
  386.       Boolean                    fDocReadData;        //USER:docs read
  387.       Boolean                    fDocWriteData;        //USER:docs write
  388.       Boolean                    fDocReadRsrc;        //USER:docs read resources
  389.       Boolean                    fDocWriteRsrc;        //USER:docs write resources
  390.       Boolean                    fDocDataStaysOpen;    //USER:docs keep file open
  391.       Boolean                    fDocRsrcStaysOpen;    //USER:docs keep resources open
  392.       Boolean                    fDocReverts;        //USER:doc can revert
  393.       Boolean                    fViewsRefViews;        //USER:views are networked together
  394.       Boolean                    fViewsSaveInPref;    //USER:view resources are written
  395.     Boolean                    fSeparatePrintView;    //USER:print views differ from screen views
  396.     Str31                    fPrefFileName;        //USER:name of preference file
  397.     Str31                    fAppName;            //USER:name of application
  398.     Str31                    fPGMAppName;        //USER:program name
  399.     Str255                    fCopyRight;            //USER:copyright string
  400.     Str255                    fAuthors;            //USER:author name string
  401.  
  402.     virtual pascal void IDrafterDoc(void);
  403.     virtual pascal void Initialize(void);
  404.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  405.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  406.     virtual pascal void Abandon(void);
  407.     virtual pascal void DoChoice(TView *origView,short itsChoice);
  408.     virtual pascal void DoInitialState(void);
  409.     virtual pascal void DoMakeViews(Boolean forPrinting);
  410.     virtual pascal void DoSetupMenus(void);
  411.     virtual pascal void EnumerateInfo(class TTranscriber *transcriber,Handle text,short kind);
  412.     virtual pascal Boolean HaveSeen(StringPtr key);
  413.     virtual pascal void SpinControl(Boolean switchOn);
  414.     virtual pascal void SpinTheCursor(void);
  415.     virtual pascal void WriteMacAppWorld(void);
  416. };
  417.  
  418.  
  419.  
  420. //This class defines a TObject performs text editing and file generation.
  421.  
  422. class TTranscriber : public TObject {
  423.   public:
  424.     TDrafterDoc                *fDocument;
  425.     short                    fFileRefNum;
  426.     Boolean                    fSingleFile;
  427.     Boolean                    fIncludes;
  428.  
  429.     virtual pascal void ITranscriber(TDrafterDoc *doc,Boolean useSingleFile,Boolean useIncludes);
  430.     virtual pascal void Initialize(void);
  431.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  432.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  433.     virtual pascal OSErr CloseFile(void);
  434.     virtual pascal void EditSection(Boolean condition,Handle data,const Str31 tagName);
  435.     virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
  436.     virtual pascal Handle GetRawData(short kind);
  437.     virtual pascal OSErr OpenFile(const Str255 name,short volRefNum,long dirId);
  438.     virtual pascal void Substitute(Handle data,const Str255 tag,const Str255 textValue);
  439.     virtual pascal OSErr WriteHandle(Handle fileText);
  440.     virtual pascal void WriteProgram(short vRefNum,long dirId);
  441.     virtual pascal void WriteProgramFile(short vRefNum,long dirId,short kind,Handle fileText);
  442. };
  443.  
  444. //This class defines a TTranscriber sensitive to Object Pascal conventions.
  445.  
  446. class TPascalTranscriber : public TTranscriber {
  447.   public:
  448.  
  449.     virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
  450.     virtual pascal Handle GetRawData(short kind);
  451. };
  452.  
  453. //This class defines a TTranscriber sensitive to C++ conventions.
  454.  
  455. class TCPlusPlusTranscriber : public TTranscriber {
  456.   public:
  457.  
  458.     virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
  459.     virtual pascal Handle GetRawData(short kind);
  460. };
  461.  
  462.  
  463.  
  464. //This class defines a TApplication that gives us MacApp® Drafter.
  465.  
  466. class TDrafterApplication : public TApplication {
  467.   public:
  468.  
  469.     virtual pascal void IDrafterApplication(void);
  470.     virtual pascal struct TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
  471.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  472.     virtual pascal void DoSetupMenus(void);
  473.     virtual pascal Boolean PickFolder(short *volRefNum,long *dirId,Str255 *name,Boolean setDefaults);
  474.     virtual pascal TWindow *WMgrToWindow(WindowPtr aWMgrWindow);
  475. };
  476.  
  477. #endif
  478.